//
//  Manyou.Toolkit.Responses.cs:
//  Authors:
//	Bryan Chow (cabir.zhou@gmail.com)
//
//
//  No Trademark License- This license does not grant you rights to use any 
//  contributors' name, logo, or trademarks.
//
//  If you bring a patent claim against any contributor over patents that you
//  claim are infringed by the software, your patent license from such 
//  contributor to the software ends automatically.
//
//  If you distribute any portion of the software, you must retain
//  all copyright, patent, trademark, and attribution notices that are present in the software.
//
//  If you distribute any portion of the software in source code form,
//  you may do so only under this license by including a complete copy of this license
//  with your distribution. If you distribute any portion of the software
//  in compiled or object code form, you may only do so under a license that complies with this license.
//
//  The software is licensed "as-is." You bear the risk of using it. 
//  The contributors give no express warranties, guarantees or conditions.
//  You may have additional consumer rights under your local laws which 
//  this license cannot change. To the extent permitted under your local laws,
//  the contributors exclude the implied warranties of merchantability,
//  fitness for a particular purpose and non-infringement.
//

using System;
using System.Xml.Serialization;
using Newtonsoft.Json;
using System.Web;
using System.Collections.Generic;

namespace Manyou.Toolkit
{

    public class ResponseBase
    {
        [JsonPropertyAttribute("errCode")]
        public int ErrorCode;

        [JsonPropertyAttribute("errMessage")]
        public string ErrorMsg;
    }

    public class UserInfoResponse : ResponseBase
    {
        [JsonPropertyAttribute("result")]
        public User[] user_array;

        [JsonIgnore]
        public User[] Users
        {
            get { return user_array ?? new User[0]; }
        }
    }

    public class LoggedInUserResponse : ResponseBase
    {
        [JsonPropertyAttribute("result")]
        public string result;

        public int Uid
        {
            get { return Util.GetIntFromString(result); }
        }
    }

    public class FriendsResponse : ResponseBase
    {
        [JsonPropertyAttribute("result")]
        public string[] uids;

        [JsonIgnore]
        public int[] UIds
        {
            get
            {
                List<int> list = new List<int>();
                for (int i = 0; i < uids.Length; i++)
                {
                    list.Add(Util.GetIntFromString(uids[i]));
                }
                //    return uids ?? new int[0]; 
                return list.ToArray();
            }
        }

        //[JsonIgnore]
        //public int[] UIds
        //{
        //    get { return uids ?? new int[0]; }
        //}
    }

    public class NotificationsResponse : ResponseBase
    {
        [JsonPropertyAttribute("result")]
        public Notifications result;
    }

    public class BooleanResponse : ResponseBase
    {
        [JsonPropertyAttribute("result")]
        public bool result;
    }

    public class StringResponse : ResponseBase
    {
        [JsonPropertyAttribute("result")]
        public string result;
    }

    public class SingleResponse<T> : ResponseBase
    {
        [JsonPropertyAttribute("result")]
        public T result;
    }


}
